import { Menus } from "../menus/menu.entity";
import { BaseEntity } from "../common/entities/base.entity";
import { User } from "../user/user.entity";
import { Column, Entity, ManyToMany, PrimaryGeneratedColumn } from "typeorm";

/**
 * 角色实体 - 用于权限管理的角色系统
 */
@Entity()
export class Roles extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number; // 角色ID (自动生成)

  @Column()
  name: string; // 角色名称

  // 多对多关系：一个角色可分配给多个用户
  @ManyToMany(() => User, (user) => user.roles)
  users: User[];

  @ManyToMany(() => Menus, (menu) => menu.roles)
  menus: Menus[];
}
